package ratons.racleurs.main;

import java.util.List;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

import data.Data_Loader;
import data.POI;
import data.Parcours;

import android.location.LocationManager;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.Menu;

public class CarteActivity extends MapActivity
{
	private Context context = this;
	private MapView mapView;
	private LocationManager lm;
	private MapController mc;
	private MyLocationOverlay myLocation = null;
	private List<Overlay> mapOverlays;
	private Drawable selected_drawable = null;
	private ItemizedOverlay selected_item;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_carte);
		
        mapView = (MapView) this.findViewById(R.id.mapView);
        mapView.setBuiltInZoomControls(true);
        
        mc = mapView.getController();
        mc.setZoom(12);
        
        /*Parcours test = Data_Loader.Parcours();
        List<POI> lst_poi = test.getListe_poi();
        
        mapOverlays = mapView.getOverlays();
        
        selected_drawable = context.getResources().getDrawable(R.drawable.ic_launcher);
        
		selected_item = new ItemizedOverlay(selected_drawable, context);
		
		for (POI item : lst_poi)
		{
			float latitude = (float) (item.getLatitude()*1E6);
			float longitude = (float) (item.getLongitude()*1E6);
	        GeoPoint geoPoint = new GeoPoint((int) latitude,(int) longitude);
	        OverlayItem overlayitem = new OverlayItem(geoPoint, item.getNom(), item.getNom());
	        selected_item.addOverlayItem(overlayitem);
		}
		
		mapOverlays.add(selected_item);
		mapView.invalidate(); // Permet de rafraichir les points*/
	}

	@Override
	protected boolean isRouteDisplayed() 
	{
		return false;
	}
}
